<?php
namespace DRY\Render;

/**
 * DonReY Framework 2012 :: Render Transform - Textile
 * Converts a string from Textile lightweight markup language to XHTML (This is actually just a wrapper for the Textile external library)
 *
 * @author Wavetrex <wavetrex@gmail.com>
 * @link http://www.donrey.net/Documentation/Structure/Modules/Render/drytemplate.html
 * @license [GPL v3] http://www.gnu.org/licenses/gpl-3.0.html
 * @version 1.0.dev
 * @package DonReY
 * @subpackage Module.Render
 */
class Transform_Textile implements Transform_base
{
	protected $CFG;

	private $Textile;

	public function __construct($CFG)
	{
		$this-> CFG = $CFG;
		$this-> Textile = new \Textile();
	}

	/**
	 * Runs the Textile engine on a string
	 * @param string $input
	 */
	public function render_String($input)
	{
		$this-> input = null;

		return $this-> Textile-> TextileThis($input);
	}

	/**
	 * Stored input string or reference - Used by __toString()
	 * @var string
	 */
	public $input;

	/**
	 * @see DRY_Render_Transform_base::__toString()
	 */
	public function __toString()
	{
		if(!is_null($this-> input))
			return $this-> render_String($this-> input);
		else
			return '';
	}

}